from os import walk

import pygame


def import_folder(path):
    surface_list = []
    for _, __, img_files in walk(path):
        for image in img_files:
            full_path = path + '/' + image
            image_surf = pygame.image.load(full_path).convert_alpha()
            # image_surf.get_rect()
            surface_list.append(image_surf)

    return surface_list


def import_folder_dict(path):
    surface_dict = {}
    for now_path, __, img_files in walk(path):
        for image in img_files:
            full_path = now_path + '/' + image
            image_surf = pygame.image.load(full_path).convert_alpha()
            state_name = now_path.split("\\")[-1]
            if state_name not in surface_dict:
                surface_dict[state_name] = []
            surface_dict[state_name].append(image_surf)
    return surface_dict
